package com.gutsyzhan.edoctor.config;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.ollama.OllamaEmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.pinecone.PineconeEmbeddingStore;
import dev.langchain4j.store.embedding.pinecone.PineconeServerlessIndexConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EmbeddingStoreConfig {
    @Autowired
    private OllamaEmbeddingModel ollamaEmbeddingModel;

    /**
     * 创建一个Pinecone的EmbeddingStore
     */
    @Bean
    public EmbeddingStore<TextSegment> embeddingStore(){
        return PineconeEmbeddingStore.builder()
                .apiKey("pcsk_ffiJ9_CsByb6uQKNvf4nYgDqpqM4zuAtDe6wPkkQnm4kWy36u2cJhr92isjmnW682nf1n")
                .index("e-doctor-index")
                .nameSpace("e-doctor-namespace")
                .createIndex(PineconeServerlessIndexConfig.builder()
                        .cloud("AWS").region("us-east-1")
                        .dimension(ollamaEmbeddingModel.dimension()).build()).build();
    }
}
